<template>
  <div>
    <h3>组件 自定义事件</h3>
    <hr>
    <!-- 利用 props 传递回调实现数据传递 -->
    <School :getSchollName="getSchollName"></School>
    <hr>
    <!-- 利用自定义事件 传递回调实现数据传递 -->
    <!-- <Student @antguigu="getStudentName"></Student> -->
    <Student ref="Stu"></Student>
  </div>
</template>

<script>
import School from "./components/School.vue";
import Student from "./components/Student.vue";

export default {
  name:"App",
  components:{
    School,
    Student
  },
  methods: {
    getSchollName(name){
      console.log('App接收到的参数是',name)
    },
    getStudentName(name) {
      console.log('App接收到的参数是',name)
    }
  },
  mounted() {
    this.$refs.Stu.$on('antguigu',this.getStudentName)
    this.$refs.Stu.$on('demo',this.getStudentName)
    // 触发一次
    // this.$refs.Stu.$once('antguigu',this.getStudentName)
  },
}
</script>